﻿using System;
using System;

namespace EmployeeDemo
{
    // 定义员工类
    internal class Employee
    {
        // 成员变量（私有字段）
        private string name;
        private int age;
        private string department;
        private double salary;

        // 无参构造方法
        public Employee() { }

        // 有参构造方法
        public Employee(string name, int age, string department, double salary)
        {
            this.name = name;
            this.age = age;
            this.department = department;
            this.salary = salary;
        }

        // Getter和Setter方法
        public string GetName()
        {
            return name;
        }

        public void SetName(string name)
        {
            this.name = name;
        }

        public int GetAge()
        {
            return age;
        }

        public void SetAge(int age)
        {
            this.age = age;
        }

        public string GetDepartment()
        {
            return department;
        }

        public void SetDepartment(string department)
        {
            this.department = department;
        }

        public double GetSalary()
        {
            return salary;
        }

        public void SetSalary(double salary)
        {
            this.salary = salary;
        }

        // 显示所有成员信息的方法
        public void DisplayInfo()
        {
            Console.WriteLine("员工信息：");
            Console.WriteLine($"姓名：{name}");
            Console.WriteLine($"年龄：{age}");
            Console.WriteLine($"部门：{department}");
            Console.WriteLine($"工资：{salary:C}"); // C表示货币格式
        }
    }

    internal class Program
    {
        static void Main(string[] args)
        {
            // 测试员工类
            Console.WriteLine("请输入员工姓名：");
            string name = Console.ReadLine();

            Console.WriteLine("请输入员工年龄：");
            int age = int.Parse(Console.ReadLine());

            Console.WriteLine("请输入员工部门：");
            string department = Console.ReadLine();

            Console.WriteLine("请输入员工工资：");
            double salary = double.Parse(Console.ReadLine());

            // 创建员工对象（通过有参构造方法）
            Employee emp = new Employee(name, age, department, salary);

            // 显示员工信息
            emp.DisplayInfo();

            // 测试getXxx和setXxx方法
            Console.WriteLine("\n修改员工信息：");
            emp.SetSalary(emp.GetSalary() + 1000); // 工资增加1000
            Console.WriteLine($"调整后的工资：{emp.GetSalary():C}");

            // 防止控制台窗口关闭
            Console.ReadKey();
        }
    }
}